home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / LOCKS.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  1KB  |  63 lines

  1. #ifndef _LINUX_LOCKS_H
  2. #define _LINUX_LOCKS_H
  3.  
  4. #ifndef _LINUX_MM_H
  5. #include <linux/mm.h>
  6. #endif
  7. #ifndef _LINUX_PAGEMAP_H
  8. #include <linux/pagemap.h>
  9. #endif
  10.  
  11. /*
  12.  * Buffer cache locking - note that interrupts may only unlock, not
  13.  * lock buffers.
  14.  */
  15. extern void __wait_on_buffer(struct buffer_head *);
  16.  
  17. extern inline void wait_on_buffer(struct buffer_head * bh)
  18. {
  19.     if (test_bit(BH_Lock, &bh->b_state))
  20.         __wait_on_buffer(bh);
  21. }
  22.  
  23. extern inline void lock_buffer(struct buffer_head * bh)
  24. {
  25.     while (test_and_set_bit(BH_Lock, &bh->b_state))
  26.         __wait_on_buffer(bh);
  27. }
  28.  
  29. extern inline void unlock_buffer(struct buffer_head *bh)
  30. {
  31.     clear_bit(BH_Lock, &bh->b_state);
  32.     wake_up(&bh->b_wait);
  33. }
  34.  
  35. /*
  36.  * super-block locking. Again, interrupts may only unlock
  37.  * a super-block (although even this isn't done right now.
  38.  * nfs may need it).
  39.  */
  40. extern void __wait_on_super(struct super_block *);
  41.  
  42. extern inline void wait_on_super(struct super_block * sb)
  43. {
  44.     if (sb->s_lock)
  45.         __wait_on_super(sb);
  46. }
  47.  
  48. extern inline void lock_super(struct super_block * sb)
  49. {
  50.     if (sb->s_lock)
  51.         __wait_on_super(sb);
  52.     sb->s_lock = 1;
  53. }
  54.  
  55. extern inline void unlock_super(struct super_block * sb)
  56. {
  57.     sb->s_lock = 0;
  58.     wake_up(&sb->s_wait);
  59. }
  60.  
  61. #endif /* _LINUX_LOCKS_H */
  62.  
  63.